import { Reducer, AnyAction } from "redux";

const dataCompute: Reducer = (state: any = { count: 0, info: "这是通知消息的初始值" }, action: AnyAction) => {
	switch (action.type) {
		case "ADD":
			return Object.assign({}, state, { count: state.count + 1 });
		case "SUB":
			return { ...state, count: state.count - 1 };
		case "BROADCAST":
			return { ...state, info: action.text };
		default:
			return state;
	}
};

export default dataCompute;
